import Mock from "mockjs";
import { MockMethod } from "vite-plugin-mock";

export default [
    {
        url: "/api/getPermissions",
        method: "get",
        timeout: 1000,
        response: ({ query }: { query: any }) => {
            console.log(query.role, "query");
            if (query.role === "financial") {
                return {
                    code: 200,
                    message: "ok",
                    data: {
                        roles: ["financial_manager"],
                        permissions: ["business:invoice:count", "business:apply:list", "business:apply:edit"],
                    },
                };
            } else if (query.role === "admin") {
                return {
                    code: 200,
                    message: "ok",
                    data: {
                        roles: ["admin"],
                        permissions: ["*:*:*"],
                    },
                };
            } else if (query.role === "operation") {
                return {
                    code: 200,
                    message: "ok",
                    data: {
                        roles: ["operation_manager"],
                        permissions: ["business:apply:delete", "business:invoice:add", "business:invoice:list"],
                    },
                };
            }
        },
    },
] as MockMethod[];
